From d9014bb4aa1120f7024119a5719bccf8b45e7179 Mon Sep 17 00:00:00 2001 From: "vhanquez@kneesa.uk.xensource.com" Date: Wed, 11 Jan 2006 12:01:37 +0000 Subject: [PATCH] update xs_transaction_t to be a plain u32 integer instead of a fake pointer. Signed-off-by: Vincent Hanquez --- linux-2.6-xen-sparse/arch/xen/kernel/reboot.c | 8 ++++---- linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c | 5 ++--- linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c | 4 ++-- linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c | 4 ++-- linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c | 5 ++--- linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c | 4 ++-- linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c | 6 ++---- linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c | 12 +++++------- linux-2.6-xen-sparse/include/asm-xen/xenbus.h | 7 +++---- tools/python/xen/lowlevel/xs/xs.c | 12 ++++++------ tools/xenstat/libxenstat/src/xenstat.c | 2 +- tools/xenstore/xenstore_client.c | 2 +- tools/xenstore/xs.c | 10 +++++----- tools/xenstore/xs.h | 5 ++--- 14 files changed, 39 insertions(+), 47 deletions(-) diff --git a/linux-2.6-xen-sparse/arch/xen/kernel/reboot.c b/linux-2.6-xen-sparse/arch/xen/kernel/reboot.c index 7a14d8b6cd..534c040c10 100644 --- a/linux-2.6-xen-sparse/arch/xen/kernel/reboot.c +++ b/linux-2.6-xen-sparse/arch/xen/kernel/reboot.c @@ -297,8 +297,8 @@ static void shutdown_handler(struct xenbus_watch *watch, return; again: - xbt = xenbus_transaction_start(); - if (IS_ERR(xbt)) + err = xenbus_transaction_start(&xbt); + if (err) return; str = (char *)xenbus_read(xbt, "control", "shutdown", NULL); /* Ignore read errors and empty reads. */ @@ -343,8 +343,8 @@ static void sysrq_handler(struct xenbus_watch *watch, const char **vec, int err; again: - xbt = xenbus_transaction_start(); - if (IS_ERR(xbt)) + err = xenbus_transaction_start(&xbt); + if (err) return; if (!xenbus_scanf(xbt, "control", "sysrq", "%c", &sysrq_key)) { printk(KERN_ERR "Unable to read sysrq code in " diff --git a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c index c5612ce48b..f3a0287935 100644 --- a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c +++ b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c @@ -310,10 +310,9 @@ static void connect(struct backend_info *be) /* Supply the information about the device the frontend needs */ again: - xbt = xenbus_transaction_start(); + err = xenbus_transaction_start(&xbt); - if (IS_ERR(xbt)) { - err = PTR_ERR(xbt); + if (err) { xenbus_dev_fatal(dev, err, "starting transaction"); return; } diff --git a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c index 9864ef0a63..3e81abe8e4 100644 --- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c +++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c @@ -170,8 +170,8 @@ static int talk_to_backend(struct xenbus_device *dev, goto out; again: - xbt = xenbus_transaction_start(); - if (IS_ERR(xbt)) { + err = xenbus_transaction_start(&xbt); + if (err) { xenbus_dev_fatal(dev, err, "starting transaction"); goto destroy_blkring; } diff --git a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c index 86798341f4..f80250d55a 100644 --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c @@ -275,8 +275,8 @@ static int talk_to_backend(struct xenbus_device *dev, goto out; again: - xbt = xenbus_transaction_start(); - if (IS_ERR(xbt)) { + err = xenbus_transaction_start(&xbt); + if (err) { xenbus_dev_fatal(dev, err, "starting transaction"); goto destroy_ring; } diff --git a/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c b/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c index f93d1c219b..4a39527711 100644 --- a/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c +++ b/linux-2.6-xen-sparse/drivers/xen/tpmback/xenbus.c @@ -236,9 +236,8 @@ static void connect(struct backend_info *be) unsigned long ready = 1; again: - xbt = xenbus_transaction_start(); - if (IS_ERR(xbt)) { - err = PTR_ERR(xbt); + err = xenbus_transaction_start(&xbt); + if (err) { xenbus_dev_fatal(be->dev, err, "starting transaction"); return; } diff --git a/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c b/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c index 488a17bd69..bb4bbe83c0 100644 --- a/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c +++ b/linux-2.6-xen-sparse/drivers/xen/tpmfront/tpmfront.c @@ -280,8 +280,8 @@ static int talk_to_backend(struct xenbus_device *dev, } again: - xbt = xenbus_transaction_start(); - if (IS_ERR(xbt)) { + err = xenbus_transaction_start(&xbt); + if (err) { xenbus_dev_fatal(dev, err, "starting transaction"); goto destroy_tpmring; } diff --git a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c index 4cfd57c34f..fc8b22453f 100644 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_dev.c @@ -147,13 +147,11 @@ static ssize_t xenbus_dev_write(struct file *filp, } if (u->u.msg.type == XS_TRANSACTION_START) { - trans->handle = (xenbus_transaction_t) - simple_strtoul(reply, NULL, 0); + trans->handle = simple_strtoul(reply, NULL, 0); list_add(&trans->list, &u->transactions); } else if (u->u.msg.type == XS_TRANSACTION_END) { list_for_each_entry(trans, &u->transactions, list) - if ((unsigned long)trans->handle == - (unsigned long)u->u.msg.tx_id) + if (trans->handle == u->u.msg.tx_id) break; BUG_ON(&trans->list == &u->transactions); list_del(&trans->list); diff --git a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c index 98498dcf97..fa404870f1 100644 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c @@ -201,7 +201,7 @@ static void *xs_talkv(xenbus_transaction_t t, unsigned int i; int err; - msg.tx_id = (u32)(unsigned long)t; + msg.tx_id = t; msg.req_id = 0; msg.type = type; msg.len = 0; @@ -424,23 +424,21 @@ EXPORT_SYMBOL(xenbus_rm); /* Start a transaction: changes by others will not be seen during this * transaction, and changes will not be visible to others until end. */ -xenbus_transaction_t xenbus_transaction_start(void) +int xenbus_transaction_start(xenbus_transaction_t *t) { char *id_str; - unsigned long id; down_read(&xs_state.suspend_mutex); id_str = xs_single(XBT_NULL, XS_TRANSACTION_START, "", NULL); if (IS_ERR(id_str)) { up_read(&xs_state.suspend_mutex); - return (xenbus_transaction_t )id_str; + return PTR_ERR(id_str); } - id = simple_strtoul(id_str, NULL, 0); + *t = simple_strtoul(id_str, NULL, 0); kfree(id_str); - - return (xenbus_transaction_t) id; + return 0; } EXPORT_SYMBOL(xenbus_transaction_start); diff --git a/linux-2.6-xen-sparse/include/asm-xen/xenbus.h b/linux-2.6-xen-sparse/include/asm-xen/xenbus.h index b6339dbc75..5534fbe99c 100644 --- a/linux-2.6-xen-sparse/include/asm-xen/xenbus.h +++ b/linux-2.6-xen-sparse/include/asm-xen/xenbus.h @@ -37,7 +37,7 @@ #include #include -#define XBT_NULL NULL +#define XBT_NULL 0 /* Register callback to watch this node. */ struct xenbus_watch @@ -102,8 +102,7 @@ int xenbus_register_frontend(struct xenbus_driver *drv); int xenbus_register_backend(struct xenbus_driver *drv); void xenbus_unregister_driver(struct xenbus_driver *drv); -struct xenbus_transaction; -typedef struct xenbus_transaction *xenbus_transaction_t; +typedef u32 xenbus_transaction_t; char **xenbus_directory(xenbus_transaction_t t, const char *dir, const char *node, unsigned int *num); @@ -116,7 +115,7 @@ int xenbus_mkdir(xenbus_transaction_t t, int xenbus_exists(xenbus_transaction_t t, const char *dir, const char *node); int xenbus_rm(xenbus_transaction_t t, const char *dir, const char *node); -xenbus_transaction_t xenbus_transaction_start(void); +int xenbus_transaction_start(xenbus_transaction_t *t); int xenbus_transaction_end(xenbus_transaction_t t, int abort); /* Single read and scanf: returns -errno or num scanned if > 0. */ diff --git a/tools/python/xen/lowlevel/xs/xs.c b/tools/python/xen/lowlevel/xs/xs.c index 5f6d1850f4..25dfaaf2a4 100644 --- a/tools/python/xen/lowlevel/xs/xs.c +++ b/tools/python/xen/lowlevel/xs/xs.c @@ -132,7 +132,7 @@ static PyObject *xspy_write(XsHandle *self, PyObject *args) if (!PyArg_ParseTuple(args, arg_spec, &thstr, &path, &data, &data_n)) return NULL; - th = (xs_transaction_t)strtoul(thstr, NULL, 16); + th = strtoul(thstr, NULL, 16); Py_BEGIN_ALLOW_THREADS result = xs_write(xh, th, path, data, data_n); @@ -264,7 +264,7 @@ static PyObject *xspy_get_permissions(XsHandle *self, PyObject *args) if (!PyArg_ParseTuple(args, arg_spec, &thstr, &path)) return NULL; - th = (xs_transaction_t)strtoul(thstr, NULL, 16); + th = strtoul(thstr, NULL, 16); Py_BEGIN_ALLOW_THREADS perms = xs_get_permissions(xh, th, path, &perms_n); @@ -320,7 +320,7 @@ static PyObject *xspy_set_permissions(XsHandle *self, PyObject *args) if (!PyArg_ParseTuple(args, "ssO", &thstr, &path, &perms)) goto exit; - th = (xs_transaction_t)strtoul(thstr, NULL, 16); + th = strtoul(thstr, NULL, 16); if (!PyList_Check(perms)) { PyErr_SetString(PyExc_RuntimeError, "perms must be a list"); @@ -519,7 +519,7 @@ static PyObject *xspy_transaction_start(XsHandle *self) th = xs_transaction_start(xh); Py_END_ALLOW_THREADS - if (th == NULL) { + if (th == XBT_NULL) { PyErr_SetFromErrno(PyExc_RuntimeError); return NULL; } @@ -556,7 +556,7 @@ static PyObject *xspy_transaction_end(XsHandle *self, PyObject *args, &thstr, &abort)) return NULL; - th = (xs_transaction_t)strtoul(thstr, NULL, 16); + th = strtoul(thstr, NULL, 16); Py_BEGIN_ALLOW_THREADS result = xs_transaction_end(xh, th, abort); @@ -740,7 +740,7 @@ static int parse_transaction_path(XsHandle *self, PyObject *args, if (!PyArg_ParseTuple(args, "ss", &thstr, path)) return 0; - *th = (xs_transaction_t)strtoul(thstr, NULL, 16); + *th = strtoul(thstr, NULL, 16); return 1; } diff --git a/tools/xenstat/libxenstat/src/xenstat.c b/tools/xenstat/libxenstat/src/xenstat.c index 921c7d29db..e8a6928dac 100644 --- a/tools/xenstat/libxenstat/src/xenstat.c +++ b/tools/xenstat/libxenstat/src/xenstat.c @@ -705,7 +705,7 @@ static char *xenstat_get_domain_name(xenstat_handle *handle, unsigned int domain snprintf(path, sizeof(path),"/local/domain/%i/name", domain_id); - name = xs_read(handle->xshandle, NULL, path, NULL); + name = xs_read(handle->xshandle, XBT_NULL, path, NULL); if (name == NULL) name = strdup(" "); diff --git a/tools/xenstore/xenstore_client.c b/tools/xenstore/xenstore_client.c index deb63453d3..07809e6c83 100644 --- a/tools/xenstore/xenstore_client.c +++ b/tools/xenstore/xenstore_client.c @@ -243,7 +243,7 @@ main(int argc, char **argv) again: xth = xs_transaction_start(xsh); - if (xth == NULL) + if (xth == XBT_NULL) errx(1, "couldn't start transaction"); ret = perform(optind, argc, argv, xsh, xth, prefix, tidy); diff --git a/tools/xenstore/xs.c b/tools/xenstore/xs.c index 8332e1aad5..f7a576119f 100644 --- a/tools/xenstore/xs.c +++ b/tools/xenstore/xs.c @@ -304,7 +304,7 @@ static void *xs_talkv(struct xs_handle *h, xs_transaction_t t, unsigned int i; struct sigaction ignorepipe, oldact; - msg.tx_id = (uint32_t)(unsigned long)t; + msg.tx_id = t; msg.req_id = 0; msg.type = type; msg.len = 0; @@ -634,21 +634,21 @@ bool xs_unwatch(struct xs_handle *h, const char *path, const char *token) /* Start a transaction: changes by others will not be seen during this * transaction, and changes will not be visible to others until end. * You can only have one transaction at any time. - * Returns NULL on failure. + * Returns XBT_NULL on failure. */ xs_transaction_t xs_transaction_start(struct xs_handle *h) { char *id_str; - unsigned long id; + xs_transaction_t id; id_str = xs_single(h, XBT_NULL, XS_TRANSACTION_START, "", NULL); if (id_str == NULL) - return NULL; + return XBT_NULL; id = strtoul(id_str, NULL, 0); free(id_str); - return (xs_transaction_t)id; + return id; } /* End a transaction. diff --git a/tools/xenstore/xs.h b/tools/xenstore/xs.h index 55bbcd157a..cabf9d0711 100644 --- a/tools/xenstore/xs.h +++ b/tools/xenstore/xs.h @@ -22,11 +22,10 @@ #include -#define XBT_NULL NULL +#define XBT_NULL 0 struct xs_handle; -struct xs_transaction_t; -typedef struct xs_transaction_t * xs_transaction_t; +typedef uint32_t xs_transaction_t; /* On failure, these routines set errno. */ -- 2.30.2